<!--
 * @Author: wangming
 * @Date: 2021-10-15 16:18:23
 * @LastEditors: wangming
 * @LastEditTime: 2021-10-21 11:15:35
 * @FilePath: /hanma-application-designer-fed/src/components/dynamicForm/syllabus/Template.vue
 * @Description: 
-->
<template>
  <div>
    <el-collapse value="0" accordion>
      <el-collapse-item title="弹框" name="0">
        <template slot="title">
          <div class="ks-row-middle-between ks-col pr20">
            <span>业务组件模版</span>
            <!-- <i class="el-icon-plus f22 iconcolor" @click.stop="add"></i> -->
          </div>
        </template>
        <div
          class="mb10 pr10 sz"
          v-for="(i, index) in TemplateButtons"
          :key="index"
        >
          <el-button @click="addModule(i)">{{ i.label }}</el-button>
        </div>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import { newform, TemplateButtons } from "./components/module.config";
import { hlTreeListSelect, hlListSelect } from "@/pageConfig/index.js";
import { cloneDeep } from "lodash";
import { uuid } from "@/utils/common.js";
import ModelForm from "./components/addForm/index";
export default {
  computed: {
    ...mapGetters(["getFormData"]),
  },
  data() {
    return {
      TemplateButtons,
    };
  },
  methods: {
    ...mapActions(["setTemplateDate", "setNavName"]),
    async addModule(row) {
      let json = cloneDeep({ hlTreeListSelect, hlListSelect });
      ModelForm.editForm({ name: row.label }, "新建业务模态框").then(
        ({ name }) => {
          let formData = newform("business");
          let config = json[row.tagName];
          config.key = "s_table_" + uuid(4);
          formData.formList = [config];
          formData.name = name;
          formData.width = 880;
          this.getFormData.template.push(formData);
          this.setTemplateDate(formData);
          this.setNavName("template");
        }
      );
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-button {
  width: 100%;
}
</style>


